package player;

import java.util.List;
import java.util.Scanner;

import pieces.Piece;


import core.Board;
import core.Color;
import core.Move;
import core.Position;

/**
 * Representation of a human player.
 * @author Tobias
 *
 */
public class HumanPlayer implements Player {
	private Color color;
	public boolean isWhite() {
		if(color.equals(Color.WHITE)) return true;
		else return false;
	}
	
	public HumanPlayer(Color color) {
		this.color = color;
	}
	
	public void setColor(Color color) {
		this.color = color;
	}

	@Override
	public Move makeMove(Board board, List<Piece> myPieces, List<Piece> yourPieces) {
		Scanner s = new Scanner(System.in);

		System.out.print("Which piece do you want to move: ");
		s.nextLine();
		System.out.print("Where do you want to move " +  ": ");
		s.nextLine();

		Position from;
		Position to;


		do {
			System.out.print("Which piece do you want to move: ");
			from = Position.parsePosition(s.nextLine());
		}while(board.getPiece(from) == null);

		do {
			System.out.print("Where do you want to move " + board.getPiece(from) + ": ");
			to = Position.parsePosition(s.nextLine());
		}while(to == null);

		return new Move(from,to);
	}

}
